﻿@model DHQGHN.PM2.Models.NhomDonViModel

@*@Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/jqueryval")*@

@using (Html.BeginForm("ActionSave", "NhomDonVi", FormMethod.Post, new { @id = "frmNhomDonVi" }))
{
    <div class="row">
        <div class="col-md-12">
            <fieldset id="fs1" class="fs_group1" style="border-style:hidden;">
                @Html.HiddenFor(m => m.NhomDonViId)
                <div class="row" style="margin-top:5px;">
                    <div class="col-md-3">
                        @Html.LabelFor(m => m.TenNhomDonVi, new { @class = "text-center", style = "" })
                        <font size="3" color="red" style="display:inline;" class="pm2-hidden">*</font>
                    </div>
                    <div class="col-md-9">
                        @Html.TextBoxFor(m => m.TenNhomDonVi, new { @class = "form-control  ", @autofocus = "autofocus", style = "", @maxlength = 50 })
                        <span style="color: red;">
                            @Html.ValidationMessageFor(m => m.TenNhomDonVi)
                        </span>
                    </div>
                </div>
                <div class="row" style="margin-top:5px;">
                    <div class="col-md-3" style="">@Html.Label("Là nhóm cơ bản: ", new { id = "lblCheck", @class = "" })</div>
                    <div class="col-md-2" style="">@Html.CheckBox("BOOL_CO_BAN")</div>
                </div>
                <div class="row" style="margin-top:5px;">
                    <div class="col-md-3">
                        <h5>@Html.LabelFor(mode => mode.GhiChu, new { @class = "text-center", style = "" })</h5>
                        <font size="3" style="display: inline; vertical-align: top; visibility:hidden;">*</font>
                    </div>
                    <div class="col-md-9">
                        @Html.TextAreaFor(m => m.GhiChu, new { @class = "form-control", @rows = 5, style = "" })
                    </div>
                </div>

            </fieldset>
        </div>
    </div>
}

@Scripts.Render("~/bundles/jqueryval")

<script>
    @functions{
            public string GetAntiForgeryToken()
            {
                string cookieToken, formToken;
                AntiForgery.GetTokens(null, out cookieToken, out formToken);
                return cookieToken + "," + formToken;
            }
        }
</script>
<script>

    var $form = $("#certification-form");
    function save() {
        var result = false;
        if ($form.valid()) {
            $.ajax({
                type: "POST",
                url: $form.attr('action'),
                data: $form.serialize(),
                dataType: '',//chú ý là form đặc biệt thì phải điền trường này
                async: false,
                headers: {
                    'VerificationToken': '@GetAntiForgeryToken()'
                },
                success: function (response) {
                    if (response != null && response.status == 200) {
                        window.notice(response.result, window.notice_success);
                        OnCriteria(0);
                        result = true;
                    } else {
                        window.notice(response.result, window.notice_error);
                    }
                }
            });
        }
        return result;
    }
</script>

